package org.batatasframework.rawdata;

import java.util.List;

import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Workbook;
import org.batatasframework.common.ParameterReader;

import cn.bonoon.entities.AbstractRawdataImportItem;
import cn.bonoon.entities.RawdataExportEntity;
import cn.bonoon.entities.RawdataImportEntity;
import cn.bonoon.kernel.support.IOperator;

public interface RawdataParser {
	List<? extends AbstractRawdataImportItem> parseWorkbook(Workbook workbook, EntityManager entityManager, ParameterReader parameter, IOperator operator) throws Exception;

	List<Object> exportItems(EntityManager entityManager, RawdataExportEntity rawdataExport);
	
	void excelExport(RawdataExportEntity rawdataExport,HttpServletResponse response,
			HttpServletRequest request,RawdataDefinition def,EntityManager entityManager);

	void excelFormat(List<Object> list,HttpServletResponse response,
			HttpServletRequest request,String fileName);
	
	List<Object> importItems(EntityManager entityManager, RawdataImportEntity rawdataImport,boolean filterDel);
	
	/** 对{@link RawdataImportEntity}对象进行初始化，如果必要的话 */
	void initImport(EntityManager entityManager, ParameterReader parameter, IOperator user, RawdataImportEntity rawdataImport);
	void initExport(EntityManager entityManager, ParameterReader parameter, IOperator user, RawdataExportEntity rawdataExport);

	/** 解析存疑的数据 */
	RawdataImportedResult parseDoubt(IOperator user, EntityManager entityManager,Long id,String[] ids);

	RawdataExportEntity addExportEntity(IOperator user, EntityManager entityManager, String[] ids);

	void deleteByImportItem(EntityManager entityManager,RawdataImportEntity rawdataImport, IOperator user) throws Exception;

	/** 禁止导入： 蒙工要求通过导入文件，对里面的treatment=0（未处理）的记录 setRecord=null	 */
	void setNullByRawdataImport(EntityManager entityManager,RawdataImportEntity rawdataImport);

	void recheck(EntityManager entityManager,
			RawdataImportEntity rawdataImport, IOperator user);
	
	
//	String parseExportName(IOperator user, RawdataExportEntity entity);
}
